/**
 * Created by Administrator on 2018/4/12.
 */
export default{
        install(Vue,options)
    {
        Vue.prototype.to = function (promise) {
            let res,err;
            promise.then(data => {
                return [data,null];
            }).catch(err => {
                return [null,err]
            })
        },
            Vue.prototype.getUrlParam = function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            },
            Vue.prototype.getUrl = function (url) {

                url="https://www.lyuanbo.club/v1/"+url
                return  url
            },
            Vue.prototype.getToken = function () {
                let user_info=  JSON.parse(localStorage.getItem('loginMessage'))
                return user_info["token"]
            },
            Vue.prototype.storageItem = function (type,name,value) {
                   if(type === 'get'){
                      return localStorage.getItem(name);
                   }else if(type === 'set'){
                        localStorage.setItem(name,value)
                      return false
                   }else {
                       console.log(name + '不存在');
                       return false
                   }
                return false
            }


    }
}